package com.abigdreamer.framework.hibernate.dao.extend;

/**
 * 装载Entity信息的内部类.  
 * 
 * @author Darkness
 * @date 2013-5-9 下午07:13:05
 * @website http://www.abigdreamer.com 
 * @version V1.0
 */
class EntityInfo { 
    boolean isUndeletable = false; // entity是否undeleteable的标志

    String statusProperty; // 标识状态的属性名

    @SuppressWarnings("rawtypes")
	public EntityInfo(Class entityClass) { 
        init(entityClass); 
    }

    /** 
     * 初始函数,判断EntityClass是否UndeletableEntity. 
     */ 
    @SuppressWarnings({ "rawtypes", "unchecked" })
	private void init(Class entityClass) { 
        // 通过EntityClass的interface判断entity是否undeletable 
        if (IUndeletableEntity.class.isAssignableFrom(entityClass)) { 
            isUndeletable = true; 
            statusProperty = IUndeleteableEntityOperation.STATUS; 
        }

        // 通过EntityClass的annotation判断entity是否undeletable 
        if (entityClass.isAnnotationPresent(IUndeletable.class)) { 
            isUndeletable = true; 
            IUndeletable anno = (IUndeletable) entityClass.getAnnotation(IUndeletable.class); 
            statusProperty = anno.status(); 
        } 
    } 
}